<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
	
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="pl" lang="pl">
	<head>
		<title>DeadTouch A.A.C. - Installation Script</title>
		<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
	</head>
	
	<body>
		<?php
			$chmods = fileperms('.');
			
			if( $perms & 0x0002 !== true or $perms & 0x0004 !== true)
				die('<p>PHP don\'t have permission to read/write this folder. Please, give a valid chmods for this folder before you install our AAC.</p>');
				
		?>
		<h1>DeadTouch Automatic Account Creator - Install</h1>
		<h3 style="color: red">DO NOT USE "\" IN PATH! IT SHOULD BE "/", NO MATTER WHAT WINDOWS THINK ABOUT IT!</h3>
		<form action="install.php" method="post">
			<p><strong>Config path:</strong> <input type="text" name="configpath" style="width: 500px;" value="For ex. C:/otserv/ (you have to provide ending '/'!)"></p>
			<p><strong>Config file:</strong> <input type="text" name="configname" value="config.lua" /></p>
			<p><input type="submit" value="Done" /></p>
		</form>
		
		<?php
		// checking config
		$confFile = file('config.php');

		if(!empty($confFile) or !file_exists('config.php'))
		{
			echo '<strong>A.A.C. is currently installed!</strong>';
			return false;
		}
	
		if( $_POST['configpath'] )
		{
			$file = <<<EOT
<?php
	static \$CONFIGDIR = "{$_POST['configpath']}";
	static \$CONFIGNAME = "{$_POST['configname']}";
?>
EOT;

			file_put_contents( 'config.php', $file );
			die( '<p>Config updated. You should be able to start A.A.C. now.<br /><a href="index.php">GO TO YOUR AAC</a></p>' );
		}
	?>
	
	</body>
</html>